home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 15319 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: mail2news.demon.co.uk!genesis.demon.co.uk
  2. From: Lawrence Kirby <fred@genesis.demon.co.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: [Q] unpack 10 bit data
  5. Date: Thu, 18 Apr 96 12:44:10 GMT
  6. Organization: none
  7. Message-ID: <829831450snz@genesis.demon.co.uk>
  8. References: <Pine.SGI.3.91.960417231151.16763A-100000@anchor.gsfc.nasa.gov>
  9. Reply-To: fred@genesis.demon.co.uk
  10. X-NNTP-Posting-Host: genesis.demon.co.uk
  11. X-Newsreader: Demon Internet Simple News v1.27
  12. X-Mail2News-Path: genesis.demon.co.uk
  13.  
  14. In article <Pine.SGI.3.91.960417231151.16763A-100000@anchor.gsfc.nasa.gov>
  15.            jyli@anchor.gsfc.nasa.gov "Jason Y. Li" writes:
  16.  
  17. >
  18. >I am looking for an efficient and elegant way of unpacking 10 bit data. 
  19. >In many scientific applications, raw data are packed into 10 bit data 
  20. >stream.  For example, an input buffer of 40 bits (5 characters) contains 
  21. >four 10-bit integers.
  22.  
  23. Do the high or low order bits for a 10 bit chunk appear first in the
  24. data stream?
  25.  
  26. > I know one way of unpacking the data which involves 
  27. >bit masking and then shifting left-and-right. It looks pretty messy to me. I 
  28. >am sure smart folks out there have better ways or ideas. I'd appreciate 
  29. >if you would let me know.
  30.  
  31. The solution will most likely involve shifting and masking. However there
  32. may perhaps be a cleaner solution than the one you saw.
  33.  
  34. -- 
  35. -----------------------------------------
  36. Lawrence Kirby | fred@genesis.demon.co.uk
  37. Wilts, England | 70734.126@compuserve.com
  38. -----------------------------------------
  39.